xenstored: Guarantee to fire @releaseDomain watch when a domain is destructed.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 24 Jul 2007 13:50:05 +0000 (14:50 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 24 Jul 2007 13:50:05 +0000 (14:50 +0100)
Previously this would be missed on some bail paths within xenstored
which would talloc_free() the connection.
Signed-off-by: Keir Fraser <keir@xensource.com>
tools/xenstore/xenstored_domain.c

index 0f6e11a29c3ee724b81937337dd6357cafa5d09f..c51e2c73b9a4c019b43da7f2c6ab08197a61d140 100644 (file)
@@ -175,6 +175,8 @@ static int destroy_domain(void *_domain)
        if (domain->interface)
                munmap(domain->interface, getpagesize());
 
+       fire_watches(NULL, "@releaseDomain", false);
+
        return 0;
 }
 
@@ -197,7 +199,7 @@ static void domain_cleanup(void)
                                continue;
                }
                talloc_free(domain->conn);
-               notify = 1;
+               notify = 0; /* destroy_domain() fires the watch */
        }
 
        if (notify)
@@ -247,7 +249,6 @@ static struct domain *new_domain(void *context, unsigned int domid,
        struct domain *domain;
        int rc;
 
-
        domain = talloc(context, struct domain);
        domain->port = 0;
        domain->shutdown = 0;
@@ -361,7 +362,7 @@ void do_introduce(struct connection *conn, struct buffered_data *in)
                /* Now domain belongs to its connection. */
                talloc_steal(domain->conn, domain);
 
-               fire_watches(conn, "@introduceDomain", false);
+               fire_watches(NULL, "@introduceDomain", false);
        } else if ((domain->mfn == mfn) && (domain->conn != conn)) {
                /* Use XS_INTRODUCE for recreating the xenbus event-channel. */
                if (domain->port)
@@ -414,8 +415,6 @@ void do_release(struct connection *conn, const char *domid_str)
 
        talloc_free(domain->conn);
 
-       fire_watches(conn, "@releaseDomain", false);
-
        send_ack(conn, XS_RELEASE);
 }